import Vue from 'vue'

import {Tooltip} from "view-design";

let page = {
  total: 1,
  startIndex: 0,
  stepNumber: 40,
  currentPage: 1
};


let data={
  terminalMarkList:[],
}

let status={
  actionModal:{
    isShow:false,
    title:'',
  },
  modifyModal:{
    isShow:false,
    isLoading:true,
    title:'',
    content:'',
  },
  decryptedModal:{
    isShow:false,
  },
  terminalMarkRules:{
    borwerFinger: [
      {required: true, message: '浏览器指纹不能为空', trigger: 'blur'}
    ],
    terminalNo:[
      {required: true, message: '电脑编号不能为空', trigger: 'blur'}
    ],

  }
};
let params={
  searchParams:{
    keyWord:"",
  },
  decryptedComputeInfo:{
    key:"",
    computeInfo:"",
    decrypted:""
  },
  datePickerOption:{
      shortcuts: [
        {
          text: '一小时后',
          value () {
            const date = new Date();
            date.setTime(date.getTime() + 3600 * 1000);
            return date;
          },
          onClick: (picker) => {
            this.$Message.info('Click today');
          }
        },
        {
          text: '一天后',
          value () {
            const date = new Date();
            date.setTime(date.getTime() + 3600 * 1000 * 24);
            return date;
          },
          onClick: (picker) => {
            this.$Message.info('Click yesterday');
          }
        },
        {
          text: '一周后',
          value () {
            const date = new Date();
            date.setTime(date.getTime() + 3600 * 1000 * 24 * 7);
            return date;
          },
          onClick: (picker) => {
            this.$Message.info('Click a week ago');
          }
        },
        {
          text: '一年后',
          value () {
            const date = new Date();
            date.setTime(date.getTime() + 3600 * 1000 * 24 * 365);
            return date;
          },
          onClick: (picker) => {
            this.$Message.info('Click a week ago');
          }
        },
      ]
  },
  chooseTime:[],
  terminalMark:{
    id:"",
    ip:"",
    borwerFinger:"",
    borwerName:"Safari",
    computeBy:"公司",
    terminalType:"1",
    terminalNo:"",
    remark:0,
    startEndTime: [],
    isLongTerm:false,
  },
};
let  tableTitles=function (self) {
  var titles =  [

    {
      width: 70,
      type: 'index',
      align: 'center'
    },
    {
      title: '浏览器指纹',
      key: 'borwerFinger',
      width: 200,
      align: 'center',
      render: (h, params) => {
        let hideName = Vue.prototype.$tiyHideUsername(params.row.borwerFinger);
        return (
          <div style="color:#207be5">
          <Tooltip content={params.row.borwerFinger}  transfer>
          {hideName}
          </Tooltip>
          </div>
      );


        return h('div',hideName);
      },


},
    {
      title: '浏览器',
      key: 'borwerName',
      width: 100,
      align: 'center',
    },
    {
      title: '终端编号',
      key: 'terminalNo',
      width: 150,
      align: 'center',

    },
    {
      title: '终端类型',
      key: 'terminalType',
      width: 150,
      align: 'center',
      render: (h, params) => {
        let terminalName = "电脑";
        if (params.row.terminalType == 1){
          terminalName = "电脑";
        }else if (params.row.terminalType == 2){
          terminalName = "手机";
        }
        return h('div',terminalName);
      },
    },
    {
      title: '备注',
      key: 'remark',
      minWidth:200,
      align: 'center',

    },
    {
    title: '创建时间',
      key: 'createtime',
      sortable: 'custom',
      width: 120,
      render: (h, params) => {
      return h('div',self.$tiyBJTime(params.row.createtime));
    },
      align: 'center'
  },
    {
      title: '操作',
      key: 'action',
      align: 'center',
      width:100,
      fixed: 'right',
      render: (h, params) => {
        return h('div', [

          self.$authority('OTHER-2-201')? h('Button', {
            props: {type: 'primary', size: 'small', icon: "ios-create",},
            style: {marginRight: '10px', marginTop: '6px', marginBottom: '6px'},
            on: {
              click: () => {
                self.modify(params.index)
              }
            }
          }, "编辑"):h('span',''),
          self.$authority('OTHER-2-202')?h('Button', {
            props: {type: 'error', size: 'small', icon: "md-trash",},
            style: {marginRight: '10px', marginTop: '6px', marginBottom: '6px'},
            on: {
              click: () => {
                self.deleteAction(params.row.id)
              }
            }
          }, "删除 "):h('span',''),
        ])
      },
    }
  ]
  return self.$authTableTitles(titles) ;
};



export  default  {
  tPage: page,
  tStatus: status,
  tParam: params,
  tData: data,
  listTableTitles:tableTitles,
};
